	<% layout('/layouts/default.html', {title: '合同表管理', libs: ['dataGrid']}){ %>

<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> 合同表管理
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
				<% if(hasPermi('fty:ftySelContract:edit')){ %>
					<a href="${ctx}/fty/ftySelContract/form" class="btn btn-default btnTool" title="新增合同表"><i class="fa fa-plus"></i> 新增</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${ftySelContract}" action="${ctx}/fty/ftySelContract/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">合同编号：</label>
					<div class="control-inline">
						<#form:input path="cNumber" maxlength="32" class="form-control width-120"/>
					</div>
				</div>



				<div class="form-group">
					<label class="control-label">买方姓名：</label>
					<div class="control-inline">
						<#form:input path="aName" maxlength="32" class="form-control width-120"/>
					</div>
				</div>


				<div class="form-group">
					<label class="control-label">卖方姓名：</label>
					<div class="control-inline">
						<#form:input path="bName" maxlength="32" class="form-control width-120"/>
					</div>
				</div>

				<div class="form-group">
					<label class="control-label">和同生成时间：</label>
					<div class="control-inline">
						<#form:input name="startDate" readonly="true" maxlength="20" class="form-control Wdate required"
								dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
						--


						<#form:input name="endDate" readonly="true" maxlength="20" class="form-control Wdate required"
								dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>

					</div>
				</div>


				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">查询</button>
					<button type="reset" class="btn btn-default btn-sm">重置</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象

<% if(mobile == 1){ %>

	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		columnModel: [

			{header:'合同编号', name:'cnumber', index:'a.c_number', width:150, align:"left"},
			{header:'房产地址', name:'haddress', index:'a.h_address', width:150, align:"left"},
			{header:'操作', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act) {
				var actions = [];
				console.log(row);
				if ((typeof(row.cnumber)) == undefined||row.cnumber==undefined) {
					row.cnumber = '';
				}
				<% if(hasPermi('fty:ftySelContract:edit')){ %>
					if(row.cnumber!=''){
						actions.push('<a href="${ctx}/fty/ftySelContract/sellercontract?contractCode='+row.contractCode+'" class="btnList" title="查看合同"><i class="fa fa-pencil"></i></a>&nbsp;');
					}else{
						actions.push('<a href="${ctx}/fty/ftySelContract/sellercontract?contractCode='+row.contractCode+'" class="btnList" title="预览合同"><i class="fa fa-eye"></i></a>&nbsp;');
						actions.push('<a href="${ctx}/fty/ftySelContract/form?contractCode='+row.contractCode+'" class="btnList" title="编辑合同"><i class="fa fa-pencil"></i></a>&nbsp;');
						actions.push('<a href="${ctx}/fty/ftySelContract/generalNumber?contractCode='+row.contractCode+'" class="btnList" title="生成编号" data-confirm="确认生成合同编号？"><i class="fa fa-home"></i></a>&nbsp;');
						actions.push('<a href="${ctx}/fty/ftySelContract/delete?contractCode='+row.contractCode+'" class="btnList" title="删除合同表" data-confirm="确认要删除该合同表吗？"><i class="fa fa-trash-o"></i></a>&nbsp;');
					}
				<%
				}
				%>
				return actions.join('');
			}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});
<%
}else{

%>

	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{header:'合同ID', name:'contractCode', index:'a.c_number', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
				return '<a href="${ctx}/fty/ftySelContract/form?contractCode='+row.contractCode+'" class="btnList" data-title="编辑合同表">'+(val||row.id)+'</a>';
			}},
			{header:'合同编号', name:'cnumber', index:'a.c_number', width:150, align:"left"},

			{header:'合同生成机构', name:'cname', index:'a.cname', width:150, align:"left"},

			{header:'买方', name:'aname', index:'a.a_name', width:150, align:"left"},
			{header:'卖方', name:'bname', index:'a.b_name', width:150, align:"left"},
			{header:'房产地址', name:'haddress', index:'a.h_address', width:150, align:"left"},


			{header:'操作员', name:'createBy', index:'a.create_by', width:150, align:"left"},
			{header:'生成时间', name:'createDate', index:'a.create_by', width:150, align:"left"},
			{header:'操作', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act) {
				var actions = [];
				console.log(row);
				if ((typeof(row.cnumber)) == undefined||row.cnumber==undefined) {
					row.cnumber = '';
				}
				<% if(hasPermi('fty:ftySelContract:edit')){ %>
					if(row.cnumber!=''){
						actions.push('<a href="${ctx}/fty/ftySelContract/sellercontract?contractCode='+row.contractCode+'" class="btnList" title="查看合同"><i class="fa fa-eye"></i></a>&nbsp;');
					}else{
						actions.push('<a href="${ctx}/fty/ftySelContract/sellercontract?contractCode='+row.contractCode+'" class="btnList" title="预览合同"><i class="fa fa-eye"></i></a>&nbsp;');
						actions.push('<a href="${ctx}/fty/ftySelContract/form?contractCode='+row.contractCode+'" class="btnList" title="编辑合同"><i class="fa fa-pencil"></i></a>&nbsp;');
						actions.push('<a href="${ctx}/fty/ftySelContract/generalNumber?contractCode='+row.contractCode+'" class="btnList" title="生成编号" data-confirm="确认生成合同编号？"><i class="fa fa-home"></i></a>&nbsp;');
						actions.push('<a href="${ctx}/fty/ftySelContract/delete?contractCode='+row.contractCode+'" class="btnList" title="删除合同表" data-confirm="确认要删除该合同表吗？"><i class="fa fa-trash-o"></i></a>&nbsp;');
					}
				<%
				}
				%>
				return actions.join('');
			}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});
<%
}
%>

</script>